package com.stephenone.zhdaily.uitl;

import java.text.ParseException;
import java.text.ParsePosition;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;

/**
 * Created by Administrator on 2018/1/16.
 */

public class DateHelper {
    public static Date strToDate(String date){
        SimpleDateFormat format = new SimpleDateFormat("yyyyMMdd");
        ParsePosition pos = new ParsePosition(0);
        return format.parse(date,pos);
    }

    public static String getSpokenDate(String strDate){
        Date date = strToDate(strDate);
        Calendar c = Calendar.getInstance();
        c.setTime(date);
        return new SimpleDateFormat("MM月dd日").format(c.getTime());
    }

    public static String getWeek(String strDate){
        Date date = strToDate(strDate);
        Calendar c = Calendar.getInstance();
        c.setTime(date);
        return new SimpleDateFormat("EEEE").format(c.getTime());
    }

    public static boolean isToday(String sdate){
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyyMMdd");
        Date today = new Date();
        String nowDate = simpleDateFormat.format(today);
        if(nowDate.equals(sdate)){
            return true;
        }
        return false;
    }

}
